/*
 * The MIT License (MIT)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package multiswarm;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.utils.Array;

/**
 * Custom class for keeping track of Agent Sensors.
 * TODO: better documentation.
 * @author ralfm
 */
public class AgentSensor {
	public Agent parentAgent;
	public int id;
	public Fixture fixture = null;
	
	public float radius;
	public float angle;
	public float offset_degrees = 0.0f;
	
	public int number_of_agents = 0;
	public Array<Agent> agents = new Array<Agent>();
	
	public Vector2 offsetVector = new Vector2(0f,0f);
	
	public boolean shouldBeRemoved = false;
	
	public AgentSensor(Agent parent, int givenId, float givenRadius, float givenAngle, float givenOffset) {
		id = givenId;
		radius = givenRadius;
		angle = givenAngle;
		offset_degrees = givenOffset;
		parentAgent = parent;
	}
	
    
    public void agentEntered(Agent agent) {
    	//Gdx.app.log("Sensor: ", "Enter");
    	agents.add(agent);
    	number_of_agents = agents.size;
    	
    }
  
    public void agentExitted(Agent agent) {
    	//Gdx.app.log("Sensor: ", "Exit");

    	agents.removeValue(agent, true);
    	number_of_agents = agents.size;
    }
}
